package com.myidis.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.myidis.entity.RightRolePermission;

public interface RightRolePermissionMapper {
	@Select("SELECT * FROM right_role_permission WHERE rid = #{id} ORDER BY pid")
    @Results({
    	@Result(property = "rid",  column = "rid"),
    	@Result(property = "pid",  column = "pid")
    })
    List<RightRolePermission> getByRole(int id);

    @Select("SELECT * FROM right_role_permission WHERE id = #{id}")
    @Results({
    	@Result(property = "rid",  column = "rid"),
    	@Result(property = "pid",  column = "pid")
    })
    RightRolePermission getOne(int id);

    @Insert("INSERT INTO right_role_permission(rid, pid) VALUES(#{rid}, #{pid})")
    int insert(RightRolePermission rightRolePermission);

    @Update("UPDATE right_role_permission SET rid = #{rid}, pid = #{pid} WHERE id = #{id}")
    int update(RightRolePermission rightRolePermission);

    @Delete("DELETE FROM right_role_permission WHERE id = #{id}")
    int delete(int id);
}
